import {types} from "mobx-state-tree";
import * as api from "./requests";

export const Home = types
  .model("Home", {})
  .volatile(self => ({
    name: "home",
    userInfo: {
      name: "store-name",
      pin: "store-pin"
    }
  }))
  .views(self => ({}))
  .actions(self => ({
		async getUserInfo(params) {
			const res = await api.getUserInfo(params);
			const result = res.data;
			self.setUserInfo(result);
		},
		setUserInfo(result) {
			console.log('setUserInfo', result);
			if (result.success) {
				self.userInfo = result.data;
			}
		},

  }));
